Dynomotion

Group: DynoMotion Message: 8915 From: ricochetproducts Date: 1/22/2014
Subject: Init file
Hi Tom,  Here is a file that I am working with. I added some more buttons. (Cyclestart, Estop, Halt, Zero,,,,) The other buttons will not work in this file since I added them.  I need to debug but I was wondering if I should run these buttons in another thread or will they be in the same thread?
  @@attachment@@
Group: DynoMotion Message: 8916 From: Tom Kerekes Date: 1/22/2014
Subject: Re: Init file [1 Attachment]
Hi Steve,

Its ok to use the same Thread.  We are just creating one big loop that does all the required tasks for your system.

But you pasted the stuff in completely the wrong place

for (;;) // loop forever
{

stuff...
stuff...
stuff...
stuff...
stuff...
stuff...
stuff...
stuff...
}


The main forever loop that does all your "stuff" looks like above.  Everything within the ope and closed curly brackets get executed repeatedly forever.  If you want to add a new task like watch a button or whatever it should be add to the list of "stuff" between the curly brackets.  I've tried to fix it up in the attached file.  Please take a moment to look it over and see if you can identify the start and end of the loop.

HTH
Regards
TK


Group: DynoMotion Message: 8917 From: Steve Klemp Date: 1/22/2014
Subject: Re: Init file [1 Attachment]
Hi Tom,  Thanks for the help!  As I have said before and I am quickly reminded, "I am not a C programmer" I am trying to learn.

Is the following correct?

for (;;) // loop forever
{     //// START OF LOOP
stuff
}
{       
stuff
}
{
more stuff
          }   //// END OF LOOP
        }
     }
}
 
.....Steve
            
 


On Wednesday, January 22, 2014 5:24 PM, Tom Kerekes <tk@...> wrote:
 
[Attachment(s) from Tom Kerekes included below]
Hi Steve,

Its ok to use the same Thread.  We are just creating one big loop that does all the required tasks for your system.

But you pasted the stuff in completely the wrong place

for (;;) // loop forever
{

stuff...
stuff...
stuff...
stuff...
stuff...
stuff...
stuff...
stuff...
}


The main forever loop that does all your "stuff" looks like above.  Everything within the ope and closed curly brackets get executed repeatedly forever.  If you want to add a new task like watch a button or whatever it should be add to the list of "stuff" between the curly brackets.  I've tried to fix it up in the attached file.  Please take a moment to look it over and see if you can identify the start and end of the loop.

HTH
Regards
TK


Group: DynoMotion Message: 8918 From: Tom Kerekes Date: 1/22/2014
Subject: Re: Init file
Hi Steve,

Yes you found the Start and End of the Loop.  I guess you are just showing a fragment of code but you included extra miss-matched curly brackets.  And also improper indentation.  Indentation (spaces or tabs) actually has no effect on the code execution but hurts my eyes to look at.  Here is some properly indented code (sometimes email messes up tabs so I hope this comes through correctly).  Notice how it is easy to see how every open curly bracket matches with a closed curly bracket on the same column.  It makes it easy to see everything in a "block" of code.  And you can see what is nested inside what.

if(A)
{
    if(B)
    {
        XXXXXX
        XXXXXX
    }
    if(C)
    {
        XXXXXX
        XXXXXX
    }
}

Regards
TK